package com.api.wall.getprivatecomments;

import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IWallApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.CollectionResultApi;
import com.zyncro.api.model.EventApi;
import com.zyncro.api.model.EventViewApiType;

@ContextConfiguration(locations = { "classpath:/wall/wall-static.xml" })
public class GetPrivateComments extends AbstractApiTest {

	@Value("#{org_staticfeeds[toGetPrivateComments].appId}")
	private String userUrn;

	@Value("#{org_staticfeeds[toGetPrivateComments].password}")
	private String userPassword;

	@Value("#{org_staticfeeds[toGetPrivateComments].totalPrivateThreads}")
	private int totalPrivateThreads;

	@Value("#{org_staticfeeds[toGetPrivateComments].totalPrivateComments}")
	private int totalPrivateComments;

	@BeforeClass
	protected void setParameters() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test
	public void testGetPrivateComments() throws ZyncroApiException {

		String date = null;
		int itemsCount = 0;
		boolean includeHtml = false;
		EventViewApiType viewType = null;
		List<String> users = null;
		boolean includeProperties = false;

		CollectionResultApi<EventApi> result = getApi().getService(IWallApiService.class).getPrivateComments(date, itemsCount, includeHtml,
				includeProperties, viewType, users);

		Assert.assertEquals(result.getElements().size(), totalPrivateThreads, "Total Private comments");
	}

	@Test
	public void testGetPrivateCommentsIncludingHtml() throws ZyncroApiException {

		String date = null;
		int itemsCount = 0;

		boolean includeHtml = true;

		EventViewApiType viewType = null;
		List<String> users = null;
		boolean includeProperties = false;

		CollectionResultApi<EventApi> result = getApi().getService(IWallApiService.class).getPrivateComments(date, itemsCount, includeHtml,
				includeProperties, viewType, users);

		Assert.assertEquals(result.getElements().size(), totalPrivateThreads, "Total Private comments");
	}

	@Test
	public void testGetPrivateCommentsBubbling() throws ZyncroApiException {

		String date = null;
		int itemsCount = 0;

		boolean includeHtml = false;
		EventViewApiType viewType = EventViewApiType.BUBBLING;
		List<String> users = null;
		boolean includeProperties = false;

		CollectionResultApi<EventApi> result = getApi().getService(IWallApiService.class).getPrivateComments(date, itemsCount, includeHtml,
				includeProperties, viewType, users);

		Assert.assertEquals(result.getElements().size(), totalPrivateThreads, "Total Private comments");
	}

	@Test
	public void testGetPrivateCommentsConversation() throws ZyncroApiException {

		String date = null;
		int itemsCount = 0;

		boolean includeHtml = false;
		EventViewApiType viewType = EventViewApiType.CONVERSATION;
		List<String> users = null;
		boolean includeProperties = false;

		CollectionResultApi<EventApi> result = getApi().getService(IWallApiService.class).getPrivateComments(date, itemsCount, includeHtml,
				includeProperties, viewType, users);

		Assert.assertEquals(result.getElements().size(), totalPrivateThreads, "Total Private comments");
	}

	@Test
	public void testGetPrivateCommentsTwitter() throws ZyncroApiException {

		String date = null;
		int itemsCount = 0;

		boolean includeHtml = false;
		EventViewApiType viewType = EventViewApiType.CONVERSATION;
		List<String> users = null;
		boolean includeProperties = false;

		CollectionResultApi<EventApi> result = getApi().getService(IWallApiService.class).getPrivateComments(date, itemsCount, includeHtml,
				includeProperties, viewType, users);

		Assert.assertEquals(result.getElements().size(), totalPrivateThreads + totalPrivateComments, "Total Private comments");
	}
}
